<template>
  <div class='content' v-loading="loading">
    <el-form :model="ruleForm"  ref="ruleForm" label-width="100px" class="demo-ruleForm">
      <el-form-item label="开启下载" prop="cert_status">
        <el-switch v-model="ruleForm.cert_status"></el-switch>
      </el-form-item>
      <el-form-item label="下载时间" required>
        <el-col >
          <el-date-picker
                v-model="ruleForm.time"
                type="datetimerange"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期">
              </el-date-picker>

        </el-col>

      </el-form-item>

      <!-- <el-form-item label="标题" prop="name">
        <el-input v-model="ruleForm.config.name"></el-input>
      </el-form-item>

      <el-form-item label="地址" prop="address">
        <el-input v-model="ruleForm.config.address"></el-input>
      </el-form-item>
      <el-form-item label="面试时间" prop="mianshi_time">
        <el-input v-model="ruleForm.config.mianshi_time"></el-input>
      </el-form-item>

      <el-form-item label="注意事项" prop="desc">
        <el-input type="textarea" v-model="ruleForm.config.desc"></el-input>
      </el-form-item> -->
      <el-form-item>
        <el-button type="primary" @click="submitForm('ruleForm')">立即保存</el-button>
        <el-button @click="resetForm('ruleForm')">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'info',
    props:['kkki_id','examid'],
    data() {
      return {
        loading: true,
        type:'info',
        ruleForm: {
          cert_status: false,
          time:'',
          config:{
            name: '',
            mianshi_time:'',
            address:'',
            desc: ''
          }
        }
      };
    },
    mounted() {
    },
    created() {
      this.init()
    },
    methods: {
      init(){
        let that = this;
        let $promise = request({url: '/kaowu/kaowu_cert_info/detail',method: 'post',data:{
            type:that.type,
            kkki_id:that.kkki_id
          }
        })
        $promise.then((res)=>{
          that.loading= false
          let info = res.data.info
          let config = info.config
          that.ruleForm.cert_status = info.cert_status
          that.ruleForm.time = info.time
          if(config){
            for(var i in config){
              that.ruleForm.config[i] = config[i]
            }
          }


          // that.ruleForm = res.data.info
          // that.$message.success(res.message)
        })
      },
      submitForm(formName) {
        let that = this;
        let request_data = { ...that.ruleForm }
        request_data.kkki_id = that.kkki_id;
        request_data.type = that.type;
        let $promise = request({url: '/kaowu/kaowu_cert_info/edit',method: 'post',data:request_data})
        $promise.then((res)=>{
          that.loading= false
          that.$message.success(res.message)
        })
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      }
    }
  }
</script>
